x86/time: reduce rounding errors in calculations
authorJan Beulich <jbeulich@suse.com>
Mon, 16 Mar 2020 16:31:35 +0000 (17:31 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 16 Mar 2020 16:31:35 +0000 (17:31 +0100)
commita60bb682190f8c0147584fa58de47528cd866be3
treeca41cebff992b46c890c13afb8622b9616195340
parent6b7860b5d04dfee4cbe0a64a4e9adc9832e2e73b
x86/time: reduce rounding errors in calculations

Plain (unsigned) integer division simply truncates the results. The
overall errors are smaller though if we use proper rounding. (Extend
this to the purely cosmetic aspect of time.c's freq_string(), which
before this change I've frequently observed to report e.g. NN.999MHz
HPET clock speeds.)

While adding the rounding logic, also switch to using an unsigned
constant for the other, original half of bus_cycle's calculation.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/apic.c
xen/arch/x86/hpet.c
xen/arch/x86/time.c